package com.hjt.zhibo.scheduler;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.hjt.zhibo.collect.ITVPlatform;
import com.hjt.zhibo.collect.impl.DouyuTV;
import com.hjt.zhibo.model.PlatFormCatalog;

public class DouyuRoomCollectTask implements Runnable{

	@Override
	public void run() {
		long startTime = System.currentTimeMillis();
		System.out.println("斗鱼房间检索任务开始..." + startTime);
		List<PlatFormCatalog> list = PlatFormCatalog.dao.find("select * from platform_catalog t where t.platform_name = ? ", "斗鱼");
		ITVPlatform douyu = new DouyuTV();
		
		//创建容量为10的线程池
		ExecutorService threadPool = Executors.newFixedThreadPool(10);
		
		for(PlatFormCatalog pfc : list){
			//douyu.getTVRoom(pfc);
			threadPool.execute(new CollectRoomThread(pfc, douyu));
		}
		
		threadPool.shutdown();
		long endTime = System.currentTimeMillis();
		System.out.println("斗鱼房间检索任务结束..." + endTime);
		System.out.println("一共花了" + (endTime-startTime) + "毫秒");
	}
	
}
